from bs4 import BeautifulSoup
import urllib

def test_beautifulsoup(url):
    req = urllib.request.Request(url)
    resp = urllib.request.urlopen(req)
    return resp.read().decode('utf-8')

if __name__ == "__main__":
    data = test_beautifulsoup("http://huaban.com/favorite/beauty")
    soup = BeautifulSoup(data, 'html.parser')
    alla = soup.find_all("a")
    print("all a: ", len(alla))
    urls = []
    for a in alla:
        if a.has_key('href'):
            urls.append(a['href'])

    for url in urls:
        print("url: ", url)